package com.cyf.db.mapper;

import com.cyf.db.bean.Users;
import org.apache.ibatis.annotations.*;


/**
 * Created by asus on 2017/6/21.
 */
@Mapper
public interface UsersMapper {

    @Select("select * from users where mobile = #{mobile}")
    Users getByMobile(@Param("mobile") String mobile);

    @Update("update users set userAuth=#{userAuth} where id=#{id}")
    void updateUsersUserAuthById(@Param("userAuth") int userAuth, @Param("id") int id);

    @Update("update users set token = #{token} where id = #{id}")
    void updateToken(@Param("token") String token, @Param("id") Integer id);

    //更新公司id
    @Update("update users set companyId=#{companyId} where id=#{id}")
    void updateCompanyIdById(@Param("companyId") int companyId, @Param("id") int id);

    @Insert("insert into users(mobile, createdTime, token, username, openid,userAuth,companyId) " +
            "values(#{users.mobile}, #{users.createdTime}, #{users.token}, #{users.username}, #{users.openid},#{users.userAuth},#{users.companyId})")
    @SelectKey(statement = "SELECT LAST_INSERT_ID()", keyProperty = "users.id", resultType = int.class, before = false)
    void insertUser(@Param("users") Users users);



}
